//
//  RecListenTableViewCell.m
//  TravelEveryDay
//
//  Created by dlios on 15-10-23.
//  Copyright (c) 2015年 com.lanou3g. All rights reserved.
//

#import "RecListenTableViewCell.h"

@implementation RecListenTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200 * HEIGHT)];
        [self.contentView addSubview:_image];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 * WIDTH, 20 * HEIGHT, SCREEN_WIDTH - 40 * WIDTH, 40 * HEIGHT)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:22];
        _titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_titleLabel];
        
        _subLabel = [[UILabel alloc] initWithFrame:CGRectMake(30 * WIDTH, 70 * HEIGHT, SCREEN_WIDTH - 60 * WIDTH, 50 * HEIGHT)];
        [_subLabel setNumberOfLines:2];
        _subLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_subLabel];
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(25 * WIDTH, 70 * HEIGHT, 1, 50 * HEIGHT)];
        lineView.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:lineView];
        
        _iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(270 * WIDTH, 150 * HEIGHT, 40 * WIDTH, 40 * WIDTH)];
        _iconImage.layer.masksToBounds = YES;
        _iconImage.layer.cornerRadius = 20 * WIDTH;
        [self.contentView addSubview:_iconImage];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(315 * WIDTH, 155 * HEIGHT, 60 * WIDTH, 30 * HEIGHT)];
        _nameLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_nameLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 * WIDTH, 150 * HEIGHT, 120 * WIDTH, 40 * HEIGHT)];
        _timeLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_timeLabel];
        
    }
    return self;
}
-(void)getData:(RecListenModel *)model
{
    [_image sd_setImageWithURL:[NSURL URLWithString:model.Cover] placeholderImage:PLACEHOLDERIMAGE];
    _titleLabel.text = model.Title;
    _subLabel.text = model.Summary;
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:model.EditorPic] placeholderImage:PLACEHOLDERIMAGE];
    _nameLabel.text = model.EditorName;
    
    //日期转换
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.CreatTime.integerValue];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY.MM.dd";
    NSString *str = [formatter stringFromDate:date];
    _timeLabel.text = str;


}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
